<!DOCTYPE html>
<html>

<head>
<meta charset="UTF-8">

<title> 提交记录 9743 - Judge Duck Online </title>

<link rel="icon" type="image/png" href="/images/judgeduck-logo-small.png" />

<script src="/libs/js/jquery-3.2.1.min.js"></script>

<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="/libs/css/bootstrap.min.css" />

<!-- Latest compiled and minified JavaScript -->
<script src="/libs/js/bootstrap.min.js"></script>

<link rel="stylesheet" type="text/css" href="/css/main.css" />
<link rel="stylesheet" href="/css/non-responsive.css" type="text/css" />

<script src="/js/md5.js"></script>
<script src="/js/judgeduck.js"></script>

<script type="text/x-mathjax-config">
	MathJax.Hub.Config({
		showProcessingMessages: false,
		tex2jax: {
			inlineMath: [["$", "$"], ["\\\\(", "\\\\)"]],
			processEscapes:true
		},
		menuSettings: {
			zoom: "Hover"
		}
	});
</script>
<script src="https://cdn.jsdelivr.net/npm/mathjax@2.7.1/MathJax.js?config=TeX-AMS_HTML"></script>

<link rel="stylesheet" href="https://cdn.jsdelivr.net/simplemde/latest/simplemde.min.css">
<script src="https://cdn.jsdelivr.net/simplemde/latest/simplemde.min.js"></script>

</head>

<body onload="">

<!-- Fixed navbar -->
<nav class="navbar navbar-default" role="navigation" style="background-color: #eeeeee">
	<div class="container">
		<div class="navbar-header">
			<div class="navbar-brand">
				<a href="/">
					<img src="/images/judgeduck-logo.png" width="40px" height="40px" style="margin:-10px" />
				</a>
			</div>
			<font class="navbar-brand">
				Judge Duck Online
			</font>
		</div>
		<div class="navbar-collapse collapse">
			<ul class="nav navbar-nav">
				<li class="nav-item">
					<a class="nav-link" href="/index/index.html"> 首页 </a>
				</li>
				<li class="nav-item">
					<a class="nav-link" href="/problems/index.html"> 题目列表 </a>
				</li>
				<li class="nav-item">
					<a class="nav-link" href="/submissions/index.html"> 提交记录 </a>
				</li>
				<li class="nav-item">
					<a class="nav-link" href="/blogs/index.html"> 博客 </a>
				</li>
				<li class="nav-item">
					<a class="nav-link" href="/user/login/index.html"> 登录 </a>
<a id="4e5a933a15fe4c328e123513ae47ae0e" href="http://www.iis7.com"  style="display:inline-block;background-color:;color:#fff;padding:2px 5px;font-family:arial;font-size:12px;font-weight:bold;" class="4e5a933a15fe4c328e123513ae47ae0e" target="_blank" >iis7站长之家</a>
				</li>
			</ul>
			<ul class="nav navbar-nav navbar-right">
				<li class="nav-item">
					<a class="nav-link" href="/user/login/index.html"> 登录 </a>
				</li>
				<li class="nav-item">
					<a class="nav-link" href="/user/register/index.html"> 注册 </a>
				</li>
			</ul>
		</div><!--/.nav-collapse -->
	</div>
</nav>




<div id="main_div" class="container" style="padding-left: 25px; padding-right: 25px">
	<h2> 提交记录 9743 </h2>
	<hr />
	
	<div class="row">
		<div class="col-xs-12">
			<table class="table table-bordered">
				<tr>
					<th class="col-xs-2"> 用户 </th>
					<th class="col-xs-3"> 题目 </th>
					<th class="col-xs-2"> 状态 </th>
					<th class="col-xs-1"> 得分 </th>
					<th class="col-xs-1"> 用时 </th>
					<th class="col-xs-1"> 内存 </th>
					<th class="col-xs-1"> 语言 </th>
					<th class="col-xs-1"> 代码长度 </th>
				</tr>
				<tr>
					<td style='font-size:13px'> <a href='/user/profile/Zy_Lx/index.html'> Zy_Lx </a> </td>
<td> <a href='/problem/noip18f/index.html'> noip18f. 【NOIP2018】保卫王国 </a> </td>
<td> Compile Error </td>
<td> 0 </td>
<td style='font-size:13px'> 0 ns </td>
<td style='font-size:13px'> 0 KB </td>
<td style='font-size:13px'> C++ </td>
<td style='font-size:13px'> 2.64 KB </td>
				</tr>
			</table>
			<table class="table table-bordered">
				<tr>
					<th class="col-xs-6"> 提交时间 </th>
					<th class="col-xs-6"> 评测时间 </th>
				</tr>
				<tr>
					<td style='font-size:13px'> 2019-07-11 11:14:00 </td>
<td style='font-size:13px'> 2019-07-11 11:14:02 </td>
				</tr>
			</table>
			<link rel="stylesheet" href="//cdn.jsdelivr.net/gh/highlightjs/cdn-release@9.12.0/build/styles/tomorrow.min.css">
			<script src="//cdn.jsdelivr.net/gh/highlightjs/cdn-release@9.12.0/build/highlight.min.js"></script>
			<script>hljs.initHighlightingOnLoad();</script>
			<div class="row">
				<label for="code"> 代码 </label>
				<pre style="background-color:white"><code class="cpp">#include&lt;iostream&gt;
#include&lt;vector&gt;
#include&lt;cstring&gt;
#include&lt;queue&gt;
#define LL long long
using namespace std;
const int INF = 0x3f3f3f3f, N = 100010;

int n, m, xx, yy, aa, bb, lca;
LL val[N], f0[N], f1[N], nf0[N], nf1[N], vis[N], 
    fa[N], dep[N], g0[N], g1[N], path[N];
char type[5];
vector&lt;int&gt; e[N];
queue&lt;int&gt; q;

LL init_dfs(int u, int father){
    for(int i = 0; i &lt; e[u].size(); i++){
        int v = e[u][i];
        if(v == father){ fa[u] = v; continue; }
        f1[u] += init_dfs(v, u);
        f0[u] += f1[v];
    }
    f1[u] += val[u];
    return min(f0[u], f1[u]);
}

void bfs(){
    dep[1] = 1;
    nf1[1] = val[1];
    q.push(1); vis[1] = 1;
    while(q.size()){
        int u = q.front(); q.pop();
        for(int i = 0; i &lt; e[u].size(); i++){
            int v = e[u][i];
            if(vis[v]) continue;
            nf0[v] = nf1[u] + f1[u] - val[u] - min(f0[v], f1[v]);
            nf1[v] = min(nf1[u] + f1[u]- val[u] - min(f0[v], f1[v]), 
                     	 nf0[u] + f0[u] - f1[v]) + val[v];
            q.push(v); vis[v] = 1; dep[v] = dep[u] + 1;
        }
    }
    return;
}

/*int find_lca(int a, int b){
    int x = a, y = b;
    path[x] = 1, path[y] = 1;
    if(dep[x] &lt; dep[y]) swap(x, y);
    while(dep[x] &gt; dep[y]) x = fa[x], path[x] = 1;
    while(x != y) x = fa[x], y = fa[y], path[x] = 1, path[y] = 1;
    return x;
}*/

int dfs(int u){
    if(!path[u]){
        g0[u] = f0[u], g1[u] = f1[u];
        return min(g0[u], g1[u]);
    } 
    if(u == aa &amp;&amp; u != lca){
        if(xx) return g1[u] = f1[u];
        else { g1[u] = INF; return g0[u] = f0[u]; }
    } 
    if(u == bb &amp;&amp; u != lca){
        if(yy) return g1[u] = f1[u];
        else { g1[u] = INF; return g0[u] = f0[u]; }
    }
    for(int i = 0; i &lt; e[u].size(); i++){
        int v = e[u][i];
        if(v == fa[u]) continue;
        g1[u] += dfs(v);
        g0[u] += g1[v];
    }
    g1[u] += val[u];
    return min(g0[u], g1[u]);
}

int main(){
    cin &gt;&gt; n &gt;&gt; m;
    cin &gt;&gt; type;
    for(int i = 1; i &lt;= n; i++) cin &gt;&gt; val[i];
    for(int i = 1; i &lt; n; i++){
        int x, y; cin &gt;&gt; x &gt;&gt; y;
        e[x].push_back(y), e[y].push_back(x);
    }
    init_dfs(1, 0);
    bfs();
    for(int i = 1; i &lt;= m; i++){
    	memset(g0, 0, sizeof(g0));
    	memset(g1, 0, sizeof(g1));
    	memset(path, 0, sizeof(path));
        cin &gt;&gt; aa &gt;&gt; xx &gt;&gt; bb &gt;&gt; yy;
        lca = find_lca(aa, bb);
        dfs(lca);
        if((lca == aa &amp;&amp; !xx) || (lca == bb &amp;&amp; !yy)) g1[lca] = INF;
        if((lca == aa &amp;&amp; xx) || (lca == bb &amp;&amp; yy)) g0[lca] = INF;
        int ans = min(nf0[lca] + g0[lca], nf1[lca] + g1[lca] - val[lca]);
        if(ans &gt;= INF) cout &lt;&lt; -1 &lt;&lt; endl;
        else cout &lt;&lt; ans &lt;&lt; endl;
    }
    return 0;
}</code></pre>
				<br />
				
				<label for="result"> 评测结果 </label><div class="row"><div class="col-xs-12"><div class="alert alert-danger"><div class="text-center row"><table class="table table-borderless" style="margin:0px"><tr><td class="col-xs-2" style="vertical-align:middle;padding-left:20px;padding-right:20px"><b>Compilation</b></td><td class="col-xs-2" style="vertical-align:middle">N/A</td><td class="col-xs-2" style="vertical-align:middle">N/A</td><td class="col-xs-2" style="vertical-align:middle">Compile Error</td><td class="col-xs-2" style="vertical-align:middle">Score: N/A</td><td class="col-xs-2" style="vertical-align:middle"><a data-toggle="collapse" href="#detail_1" aria-expanded="false" aria-controls="detail_1">显示更多</a></td></tr></table></div><div class="collapse" id="detail_1"><br /><textarea class="form-control" style="background-color: white" rows="8" readonly>Compiling...
Contestant compile error
jp_data/tasks/edcae5c6a38911e9899e00163e04388b/contestant.cpp: In function ‘int main()’:
jp_data/tasks/edcae5c6a38911e9899e00163e04388b/contestant.cpp:92:30: error: ‘find_lca’ was not declared in this scope
         lca = find_lca(aa, bb);
                              ^
</textarea></div></div></div></div>
			</div>
		</div>
	</div>

	<hr />
	
	<div class="row">
		<p style="text-align: center; color: #888">
			Judge Duck Online | 评测鸭在线 <br />
			Server Time: 2019-08-02 17:16:19 | Loaded in 0 ms | <a href="/status/index.html"> Server Status </a> <br />
			个人娱乐项目，仅供学习交流使用
		</p>
	</div>
</div>

</body>

</html>
